package Atm01;

import Polymorphic.Student;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * GUI版本的ATM窗口
 */
public class ATMFrame extends JFrame {
    private Image bgImage = new ImageIcon("Images/background.jpg").getImage();
    private Image logoImg = new ImageIcon("Images/555.jpg").getImage();
        private LoginPanel loginPanel = new LoginPanel(this);
    private MenuPanel menuPanel = new MenuPanel(this);
    private SavePanel savePanel=new SavePanel(this);
    private GetPanel getPanel=new GetPanel(this);
    private SearchPanel searchPanel = new SearchPanel(this);
       private ChangePwdPanel changePwdPanel=new ChangePwdPanel(this);
         private TransferPanel transferPanel=new TransferPanel(this);

    public TransferPanel getTransferPanel() {
        return transferPanel;
    }

    public void setTransferPanel(TransferPanel transferPanel) {
        this.transferPanel = transferPanel;
    }

    private SuperArray users = new SuperArray();
    private User loginUser;


    public User getLoginUser() {
        return loginUser;
    }



    public void setLoginUser(User loginUser) {
        this.loginUser = loginUser;
    }

    private JButton button1 = new JButton("long");

    public SuperArray getUsers() {
        return users;
    }

    public void setUsers(SuperArray users) {
        this.users = users;
    }

    private CardLayout cardLayout = new CardLayout();

//    public void init() {
//        users.add(new User("tom", "111111", 2000));
//        users.add(new User("蜘蛛侠", "111111", 2500));
//        users.add(new User("喜羊羊", "1234", 3000));
//        users.add(new User("佩奇", "12345", 2700));
//        users.add(new User("乔治", "123456", 1200));
//
//    }

    public SearchPanel getSearchPanel() {
        return searchPanel;
    }

    public ATMFrame() {
//        this.init();

        this.setContentPane(new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(bgImage, 0, 0, this);
            }
        });
        this.setLayout(cardLayout);

        this.add("login", loginPanel);
        this.add("menu",menuPanel);
        this.add("save",savePanel);
        this.add("get",getPanel);
        this.add("searchPanel", searchPanel);
        this.add("changPwd",changePwdPanel);
        this.add("transferPanel", transferPanel);

        this.setIconImage(logoImg);
        this.setSize(1024, 768);
        this.setTitle("ATM");
        this.setResizable(false);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
    }

    public SavePanel getSavePanel() {
        return savePanel;
    }

    public void switchPanel(String name) {
        cardLayout.show(this.getContentPane(), name);
    }


    public static void main(String[] args) {
        new ATMFrame();
    }


}
